package com.liuzy.entity;

import cn.afterturn.easypoi.excel.annotation.*;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@ExcelTarget("users")
public class User implements Serializable {
   // @ExcelIgnore 表示此列不导出
    @Excel(name = "编号",orderNum = "0")
    private Integer id;
    @Excel(name = "姓名",orderNum = "1")
    private String name;
    @Excel(name = "年龄",orderNum = "2")
    private Integer age;
    @Excel(name = "生日",width = 35.0,orderNum = "3",format = "yyyy-MM-dd HH:mm:ss")
    private Date bir;
    /**
     * replace 替换 _前面替换后面的
     */
    @Excel(name = "用户状态",replace = {"激活_1","锁定_0"},orderNum = "4")
    private String status;

    /**
     * 用户爱好可能是多个 集合
     */
    @ExcelIgnore
    private List<String> habbys;
    @Excel(name = "爱好",orderNum = "5",width = 30.0)
    private String habbysStr;

    /**
     * 包含card
     *  @ExcelEntity 标志一一对应
     */
    @ExcelEntity
    private Card card;
    /**
     * 标识一对多
     */
    @ExcelCollection(name = "订单列表" ,orderNum = "8")
    private List<Order> orders;
    @ExcelIgnore
    //@Excel(name = "头像信",width = 60.0,height = 60.0,type = 2) //type为2为图片类型
    private String photo; //头像
    public String getHabbysStr() {
        StringBuilder sb = new StringBuilder();
        habbys.forEach(e->{
            sb.append(e+"、");
        });
        return sb.toString();
    }

    public void setHabbysStr(String habbysStr) {
        this.habbysStr = habbysStr;
    }
}
